package com.liuche.book.auth.alarm;

import com.liuche.book.auth.alarm.impl.MailAlarmHelper;
import com.liuche.book.auth.alarm.impl.SmsAlarmHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author：liuche
 * @Date：2024年06月29日 21:09
 * @Description：
 */
@Slf4j
@Configuration
@RefreshScope
public class AlarmConfig {
    @Value("${alarm.type}")
    private String alarmType;

    @Bean
    @RefreshScope
    public AlarmInterface alarmHelper() {
        if (alarmType.equals("sms")) {
            log.info("短信类型告警通知");
            return new SmsAlarmHelper();
        } else {
            log.info("邮箱类型告警通知");
            return new MailAlarmHelper();
        }
    }
}
